package Code;

import java.util.Arrays;
import java.util.stream.Collectors;

public class Code73 {
    static void setZeros(int[][] matrix){
        boolean[] flag1 = new boolean[matrix.length];
        boolean[] flag2 = new boolean[matrix[0].length];

        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if(matrix[i][j] == 0){
                    flag1[i] = true;
                    flag2[j] = true;
                }
            }
        }
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if(flag1[i]|| flag2[j]){
                    matrix[i][j] = 0;
                }
            }
        }
    }
    public static void main(String[] args) {
        int[][] m = new int[][]{{1,1,1},{1,0,1},{1,1,1}};
        setZeros(m);
        System.out.println(Arrays.stream(m)
                .map(a-> Arrays.stream(a).boxed().toList()).collect(Collectors.toList()));
    }
}
